/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package carstore.userserver.controllers;
import carstore.userserver.models.User;
import carstore.userserver.services.UserRepository;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author wuhao
 */
@RestController
public class UserController {
	@Autowired
	private UserRepository UserRepositoryImpl;
	
	@RequestMapping("/count")
	public long getUsercount()
	{
		return UserRepositoryImpl.count();
	}
	@RequestMapping("/user")
	public List<User> getUserByID(Integer UserId)
	{
		return UserRepositoryImpl.findByuserId(UserId);
	}
	
	@RequestMapping("/all")
	public List<User> getall()
	{
            //System.out.println("UserController get all users...");
		return (List<User>) UserRepositoryImpl.findAll();
	}
	
	@RequestMapping("/getuser")
	public List<User> getUserbyUserId(int UserId)
	{
		return (List<User>)UserRepositoryImpl.findByuserId(UserId);
	}
}
